﻿using LowCoding.Domain.Entity;
using LowCoding.Dto.Sys;
using Mapster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LowCoding.Application.Sys.Role
{
    public class SysUserroleService : ServiceBase<SysUserrole, SysUserroleInput, SysUserroleOutput, SysUserroleSearchInput, string>, ISysUserroleService
    {
        //用户添加角色信息
        public async Task<SysUserroleOutput> AddUserRoleAsync(SysUserroleInput input)
        {
            try
            {
                string[] keyarray = GetPrimaryKeys(typeof(SysUserrole));
                var entity = GetEntity(input, keyarray);
                //连接数据库，进行异步添加操作
                await _client.Insertable(entity).ExecuteCommandAsync();
                return entity.Adapt<SysUserroleOutput>();//映射dto进行显示
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
